import { createRouter, RouteRecordRaw, createWebHashHistory, createWebHistory } from "vue-router";

declare module "vue-router" {
    interface RouteMeta {
        title: string,
        transition: string
    }
}


const routes: Array<RouteRecordRaw> = [
    {
        path: '/index',
        component: () => import('../components/index.vue'),
        meta: {
            title: "首页",
            transition: "animate__fadeIn "
        }
    },
    {
        path: '/',
        component: () => import('../components/Login.vue'),
        meta: {
            title: "登录页面",
            transition: "animate__bounceOut"
        }
    }
]


const router = createRouter({
    history: createWebHistory(),
    routes,
    scrollBehavior(to, from, savedPosition) {
        // console.log(savedPosition)
        if (savedPosition) {
            // return savedPosition
            return {
                top:99999
            }
            // return new Promise((r)=>{
            //     setTimeout(()=>{
            //         r({
            //             top:99999
            //         })
            //     },2000)
            // })
        } else {
            return {
                top: 0
            }
        }
    }
})

export default router

